﻿namespace CommLib
{
    enum StatusType
    {
        Alive, SmsSent, SmsDelivered, SmsReceived, Unknown
    }

    class MessageStatus : BluetoothMessage
    {
        public readonly static int SMS_SENT_SUCCESS = 1;
	    public readonly static int SMS_SENT_ERROR = 0;
	    public readonly static int SMS_SENT_NO_SERVICE = 2;
	    public readonly static int SMS_SENT_NULL_PDU = 3;
	    public readonly static int SMS_SENT_RADIO_OFF = 4;

	    public readonly static int SMS_DELIVERED_SUCCESS = 1;
	    public readonly static int SMS_DELIVERED_ERROR = 0;

	    public MessageStatus(StatusType type)
            : this(type, -1)
        {
	    }

	    public MessageStatus(StatusType type, int value) 
            : base(BtMessageType.Status, new string[] { ((int)type).ToString(), value.ToString() })
        {
	    }

	    public MessageStatus(byte[] data, int length)
            : base(BtMessageType.Status, data, length)
        {
	    }

	    public StatusType getType() {
		    if (mData[0] != null) {
			    int idx = int.Parse(mData[0]);

			    if (idx >= 0)
				    return (StatusType)idx;
		    }

		    return StatusType.Unknown;
	    }

	    public int getValue() {
		    if (mData[1] != null)
                return int.Parse(mData[1]);

		    return -1;
	    }
    }
}
